package com.boge.parse.base;

import com.boge.decoder.AES;
import org.apache.mina.core.session.AttributeKey;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoder;

public abstract class BaseProtocolEncoder implements ProtocolEncoder  {


    /**
     * 获取对象保存的 aes
     * @param session 通信
     * @param CONTEXT 保存key
     * @return
     */
    protected AES getAes(IoSession session, AttributeKey CONTEXT) {
        AES aes;
        aes = (AES) session.getAttribute(CONTEXT);
        if (aes == null) {
            aes = new AES();
            session.setAttribute(CONTEXT, aes);
        }
        return aes;
    }

}
